var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');


module.exports = {
    devtool: '#source-map',

    entry: {
        index: './src/client/index',
        vendor: ['react', 'react-dom', 'react-router', 'antd', 'dva', 'prop-types']
    },
    output: {
        filename: '[name].bundle.js',
        path: path.join(__dirname, './src/static'),
        publicPath: '/static/',
    },
    resolve: {
        extensions: [' ', '.css', '.scss', '.sass', '.less', '.js', '.json']
    },
    module: {
        loaders: [
            {
                test: /\.json$/,
                loader: "json-loader"
            },
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.less$/,
                loader: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader!less-loader" })
            },
            {
                test: /\.css$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'css-loader?sourceMap&modules&localIdentName=[local]'
                )
            },
            {
                test: /\.css$/,
                include: /node_modules/,
                loader: ExtractTextPlugin.extract(
                    'css-loader?sourceMap&modules&localIdentName=[local]'
                )
            
            }

        ]
    },
    plugins: [
       
        new webpack.optimize.UglifyJsPlugin({
            output: {
                comments: false,
            },
            compress: {
                warnings: false
            }
        }),
        new webpack.optimize.CommonsChunkPlugin({
            names: ['vendor'],
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify("production"),
            },

        }),
        new ExtractTextPlugin("[name].css", {
            disable: false,
            allChunks: true,
        })

    ]
}

